package com.sy.demo.quartz;

import java.util.Date;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;

public class JobManager {

	public Scheduler sched = null; //单一调度器
	public int flag = 0;
	
	public JobManager() {
		SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
		try {
			sched = schedFact.getScheduler(); //通过工厂取实例
			sched.start(); 
			System.out.println(sched.getSchedulerName());
			System.out.println(sched.getClass());
		} catch (SchedulerException e) {
			e.printStackTrace();
		}
		simpleTriggleStart();
	}
	
	public void simpleTriggleStart(){
		try {
			JobDetail deviceJobDetail = new JobDetail("deviceJob", "syjob",SYJob.class); //具体任务
			Trigger deviceTrigger = TriggerUtils.makeMinutelyTrigger(1);
			deviceTrigger.setStartTime(new Date());
			deviceTrigger.setName("deviceTrigger");
			
			sched.scheduleJob(deviceJobDetail, deviceTrigger);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String [] args)
	{
		JobManager manager = new JobManager();
		
	}
	
}
